{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            min-height: 100vh;
            display: flex;
            background: #f0f2f5;
        }

        .background {
            flex: 1;
            background-image: url({% static 'img/2.jpg' %}); /* 添加背景图片 */
            background-size: contain; /* 使背景图片覆盖整个区域 */
            background-position: center; /* 将背景图片居中 */
            background-repeat: no-repeat;
        }

        .login-container {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 2rem;
        }

        .login-form {
            width: 100%;
            max-width: 400px;
            background: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        h2 {
            text-align: center;
            color: #1a73e8;
            margin-bottom: 1.5rem;
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        label {
            display: block;
            margin-bottom: 0.5rem;
            color: #5f6368;
        }

        input {
            width: 100%;
            padding: 0.8rem;
            border: 1px solid #dadce0;
            border-radius: 4px;
            font-size: 16px;
        }

        input:focus {
            outline: none;
            border-color: #1a73e8;
            box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
        }

        button {
            width: 100%;
            padding: 0.8rem;
            background: #1a73e8;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            transition: background 0.3s ease;
        }

        button:hover {
            background: #1557b0;
        }

        .error-message {
            color: #dc3545;
            font-size: 0.9rem;
            margin-top: 0.5rem;
        }
    </style>
</head>
<body>
    <div class="background"></div>
    <div class="login-container">
        <div class="login-form">
            <form id="loginForm" action="{% url 'login' %}" method="post">
                {% csrf_token %}
                <h2>用户登录</h2>
                <div class="form-group">
                    <label for="username">用户名：</label>
                    <input type="text" id="username" name="username" required>
                    {% if form.username.errors %}
                        <div class="error-message">{{ form.username.errors.as_text }}</div>
                    {% endif %}
                </div>

                <div class="form-group">
                    <label for="password">密码：</label>
                    <input type="password" id="password" name="password" required>
                    {% if form.password.errors %}
                        <div class="error-message">{{ form.password.errors.as_text }}</div>
                    {% endif %}
                </div>
                <label for="captcha">验证码:</label>
    <input type="text" id="captcha" name="captcha"><br>
    <img src="{% url 'captcha' %}" alt="验证码" onclick="this.src='{% url 'captcha' %}?'+Math.random();"><br><br>
                <div class="form-group">
                    <button type="submit">立即登录</button>
                </div>
            </form>
        </div>
    </div>

</body>
</html>
